package com.github.cyf.async.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author chenyifan
 * @create 2024-03-17 18:48
 */
@Service
@Slf4j
public class AsyncService {

    @Async
    public void sendMessage(String msg) {
        try {
            Thread.sleep(3000);
            log.info("发送信息：{}", msg);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    @Async
    public void sendError(String msg) {
        log.error("执行出错");
        int a = 1 / 0;
    }
}
